package com.srxz.personnelsystem.system.service.mapimpl;

import com.srxz.personnelsystem.system.entity.LoginInfo;
import com.srxz.personnelsystem.system.entity.Position;
import com.srxz.personnelsystem.system.mapper.converter.PositionMapper;
import com.srxz.personnelsystem.system.mapper.dto.DepartmentDTO;
import com.srxz.personnelsystem.system.mapper.dto.UserInfoDTO;
import com.srxz.personnelsystem.system.repository.PositionRepository;
import com.srxz.personnelsystem.system.service.BaseService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * @ClassName: DepartmentMapperServiceImpl
 * @author: wgchao
 * @createTime: 2019/1/23 5:15 PM
 * @Description: TODO
 */
public class DepartmentMapperServiceImpl extends BaseService<DepartmentDTO> {
    @Autowired
    private PositionRepository positionRepository;
    @Autowired
    private PositionMapper positionMapper;

    public DepartmentMapperServiceImpl extendPositionDTOS(DepartmentDTO departmentDTO){
        if(!StringUtils.isEmpty(departmentDTO.getId())){
            List<Position> positions = positionRepository.findAllOfDepartment(departmentDTO.getId());
            if(positions!=null && !positions.isEmpty()){
                setAttribute(departmentDTO, "positionDTOS", positionMapper.dto(positions));
            }
        }
        return this;
    }

}
